home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1990-1992 by Michael Davidson.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software
- * and its documentation for any purpose and without fee is hereby
- * granted, provided that the above copyright notice appear in all
- * copies and that both that copyright notice and this permission
- * notice appear in supporting documentation.
- *
- * This software is provided "as is" without express or implied warranty.
- */
-
- /*
- * paradise.c - support routines for Paradise PVGA1 and WDC90C00 family
- */
-
- #include "vdev.h"
- #include "svga.h"
-
- /*
- * table of video modes supported for PVGA1 and WDC90C00
- */
- #define GRAPHICS (SVGA_MODE_SUPPORTED | SVGA_GRAPHICS_MODE)
- #define TEXT (SVGA_MODE_SUPPORTED | SVGA_TEXT_MODE)
-
- static struct svga_mode_info paradise_modes[] =
- {
- { 640, 480, 24, 0x72, GRAPHICS },
- { 800, 600, 15, 0x63, GRAPHICS },
- { 640, 480, 15, 0x62, GRAPHICS },
- { 1024, 768, 8, 0x60, GRAPHICS },
- { 800, 600, 8, 0x5c, GRAPHICS },
- { 640, 480, 8, 0x5f, GRAPHICS },
- { 640, 400, 8, 0x5e, GRAPHICS },
- { 320, 200, 8, 0x13, GRAPHICS },
- { 132, 28, 0, 0x47, TEXT },
- { 80, 25, 0, 0x03, TEXT },
- { 0, 0, 0, 0x00, 0 }
- };
-
- static char *paradise_chip_type();
- static int paradise_get_memory_size();
- static void paradise_bank_switch();
- static void paradise_enable_extensions();
-
- extern unsigned char *VideoBiosAddress;
-
- /*ARGSUSED*/
- int
- paradise_init(
- char *name,
- vdev_t *v
- )
- {
- int r;
- struct svga_mode_info *s;
- int mem;
-
- if (! (r = paradise_present()))
- return -1;
-
- paradise_enable_extensions();
-
- mem = paradise_get_memory_size();
-
- for (s = paradise_modes; s->attributes != 0; s++)
- {
- int m;
-
- m = s->width * s->height * ((s->depth + 7) >> 3);
- m /= 1024;
-
- if (m > mem || (! svga_mode_supported(s->bios_mode)))
- s->attributes &= ~SVGA_MODE_SUPPORTED;
- }
-
- svga_setup(v, paradise_modes, paradise_bank_switch);
-
- v->v_name = paradise_chip_type();
-
- return 0;
- }
-
- int
- paradise_probe()
- {
- return paradise_present();
- }
-
- int
- paradise_present()
- {
- /*
- * check for Paradise signature in BIOS
- */
- return (memcmp(VideoBiosAddress + 0x7d, "VGA=", 4) == 0);
- }
-
- static void
- paradise_enable_extensions()
- {
- outb(0x3ce, 0x0f); /* unlock PR0 - PR4 */
- outb(0x3cf, 0x05);
-
- outb(0x3d4, 0x29); /* unlock PR1A, PR11 - PR17 */
- outb(0x3d5, 0x85);
-
- outb(0x3c4, 0x06); /* unlock extended sequencer */
- outb(0x3c5, 0x48);
- }
-
- static char *
- paradise_chip_type()
- {
- unsigned char old, new;
- char *p;
-
- outb(0x3d4, 0x2b);
- old = inb(0x3d5);
- outb(0x3d5, 0xaa);
- new = inb(0x3d5);
- outb(0x3d5, old);
-
- if (new != 0xaa)
- return "Paradise PVGA1";
-
- outb(0x3c4, 0x12);
- old = inb(0x3c5);
- outb(0x3c5, old & 0xbf);
- new = inb(0x3c5) & 0x40;
- if (new != 0)
- {
- outb(0x3c5, old);
- return "Paradise WD90C00";
- }
-
- outb(0x3c5, old | 0x40);
- new = inb(0x3c5) & 0x40;
- outb(0x3c5, old);
- if (new == 0)
- return "Paradise WD90C00";
-
- p = "WD90C11";
- outb(0x3c4, 0x10);
- old = inb(0x3c5);
-
- outb(0x3c5, old & 0xfb);
- new = inb(0x3c5) & 0x04;
- if (new != 0)
- p = "Paradise WD90C10";
-
- outb(0x3c5, old | 0x04);
- new = inb(0x3c5) & 0x04;
- if (new == 0)
- p = "Paradise WD90C10";
-
- outb(0x3c5, old);
- return p;
- }
-
- static int
- paradise_get_memory_size()
- {
- int x;
-
- outb(0x3ce, 0x0b);
- x = inb(0x3cf);
- x = (x >> 6) & 3;
-
- if (x == 0 || x == 1)
- return 256;
- if (x == 2)
- return 512;
- return 1024;
- }
-
- /*
- * paradise_bank_switch()
- */
- static void
- paradise_bank_switch(
- int x
- )
- {
- outb(0x3ce, 0x0f); /* unlock extended registers */
- outb(0x3cf, 0x05);
-
- outb(0x3ce, 0x09);
- outb(0x3cf, x << 4);
- }
-